//
//  DYRechargeSetVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/17.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYRechargeSetVC.h"
#import "DYRechargeSetHeaderView.h"
#import "DYRechargeSetCell.h"
#import "DYRechargeMoneySetVC.h"

@interface DYRechargeSetVC ()

@property (nonatomic,strong)DYRechargeSetHeaderView *headerView;

@end

@implementation DYRechargeSetVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self navigationSet];
}
-(void)navigationSet
{
    self.navigationItem.title=@"充值设置";
    [self createRightBarItem:nil titleString:@"新增金额"];
    
    UIButton *rightBtn=self.navigationItem.rightBarButtonItem.customView;
    [rightBtn setTitleColor:[UIColor xhq_content] forState:UIControlStateNormal];
}
-(void)rightClick
{
    DYRechargeMoneySetVC *vc=[[DYRechargeMoneySetVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    [self.view addSubview:self.headerView];
    
    self.tableView.backgroundColor=WhiteColor;
    self.tableView.frame=CGRectMake(0, BILIHEIGHT(40), kScreenWidth, kScreenHeight-kNavigationStatusHeight-BILIHEIGHT(40));
    
    [self.tableView registerClass:[DYRechargeSetCell class] forCellReuseIdentifier:@"DYRechargeSetCell"];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return BILIHEIGHT(40);
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DYRechargeSetCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYRechargeSetCell" forIndexPath:indexPath];
    return cell;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    editingStyle=UITableViewCellEditingStyleDelete;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}
-(NSArray <UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        NSLog(@"点击了删除");
   
    }];
    deleteAction.backgroundColor=[UIColor xhq_red];
    UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"设置" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

        DYRechargeMoneySetVC *vc=[[DYRechargeMoneySetVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }];
    editAction.backgroundColor = [UIColor xhq_base];
    return @[deleteAction, editAction];
}

-(DYRechargeSetHeaderView *)headerView
{
    if (!_headerView) {
        _headerView=[[DYRechargeSetHeaderView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, BILIHEIGHT(40))];
    }
    return _headerView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
